package com.qiall.gateway.controller.convert;

import com.qiall.gateway.controller.request.ApiDTO;
import com.qiall.gateway.controller.request.AddApiRequest;
import com.qiall.gateway.controller.request.QueryApiInfoRequest;
import com.qiall.gateway.data.entity.ApiInfo;
import org.springframework.stereotype.Component;

/**
 * @author 吴金辉
 */
@Component
public class ApiInfoTrans {
    public ApiInfo trans(AddApiRequest addApiRequest) {
        ApiInfo apiInfo = new ApiInfo();

        apiInfo.setApiName(addApiRequest.getApiName());
        apiInfo.setApiPath(addApiRequest.getApiPath());
        apiInfo.setAppName(addApiRequest.getAppName());
        apiInfo.setApiDescription(addApiRequest.getApiDescription());
        apiInfo.setServiceName(addApiRequest.getServiceName());
        apiInfo.setMethodName(addApiRequest.getMethodName());
        apiInfo.setVersion(addApiRequest.getVersion());
        apiInfo.setId(addApiRequest.getId());
        return apiInfo;
    }

    public ApiInfo trans(QueryApiInfoRequest request) {
        ApiInfo apiInfo = new ApiInfo();
        apiInfo.setApiName(request.getApiName());
        apiInfo.setApiPath(request.getApiPath());
        apiInfo.setAppName(request.getAppName());
        apiInfo.setApiDescription(request.getApiDescription());
        apiInfo.setServiceName(request.getServiceName());
        apiInfo.setMethodName(request.getMethodName());
        apiInfo.setVersion(request.getVersion());
        return apiInfo;
    }

    public ApiDTO trans(ApiInfo request){
        ApiDTO apiDTO = new ApiDTO();
        apiDTO.setId(request.getId());
        apiDTO.setApiName(request.getApiName());
        apiDTO.setApiPath(request.getApiPath());
        apiDTO.setAppName(request.getAppName());
        apiDTO.setApiDescription(request.getApiDescription());
        apiDTO.setServiceName(request.getServiceName());
        apiDTO.setMethodName(request.getMethodName());
        apiDTO.setVersion(request.getVersion());
        return apiDTO;
    }
}
